<?php

declare(strict_types=1);

namespace App\Controller;

use App\Model\data\CurrentShopData;
use App\Model\data\CurrentUserData;
use Hyperf\Di\Annotation\Inject;
use App\Service\NotifyLog\NotifyLogService;

/**
 * 通知消息
 */
class NotifyLogController extends AbstractController
{

    /**
     * 物流等信息
     * @Inject
     * @var NotifyLogService
     */
    private  $notifyLogService;

    public function shop_list()
    {
        $is_read = $this->request->input('is_read','');
        $up_time = $this->request->input('up_time','0');
        $shop_info  = CurrentShopData::getData();
        $list =  $this->paginate($this->notifyLogService->list(intval($shop_info->id),2,$up_time))->toArray();
        $list['un_read'] = $this->notifyLogService->count_size(intval($shop_info->id),2,$shop_info->last_notify_time);
//        物流更新信息
        return $this->jsonResponse->success($list,'信息列表');
    }

    public function user_list()
    {
        $is_read = $this->request->input('is_read','');
        $up_time = $this->request->input('up_time','0');
        $user_info  = CurrentUserData::getData();
        $list =  $this->paginate($this->notifyLogService->list(intval($user_info->id),1,$up_time))->toArray();
        $list['un_read'] = $this->notifyLogService->count_size(intval($user_info->id),1,$user_info->last_notify_time);
//        物流更新信息
        return $this->jsonResponse->success($list,'信息列表');
    }

}